//
// Created by Administrator on 2023/11/13.
//
#include "iostream"

using namespace std;


int main() {
    int m, n;
    cin >> n >> m;
    int A[n+1], ans[m+1], sum[n+1];
    for (int i = 1; i <= n; ++i) {
        cin >> A[i];
        sum[i] = 0;
    }
    sum[0]=0;
    for (int i = 1; i <= n; ++i) {
        sum[i] = A[i] + sum[i - 1];
    }
    for (int i = 1; i <= m; i++) {
        int l, r;
        cin >> l >> r;
        ans[i] = sum[r] - sum[l-1];
    }
    for (int i = 1; i <=m; ++i) {
        cout << ans[i] << endl;
    }
}